package com.geekaca.chat.test;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class MyFrame extends JFrame {

    public MyFrame() {
//        URL imgUrl = MyFrame.class.getResource("F:\\Geeka\\lh\\JavaSE_Senior\\day13\\chatRoom\\src\\com\\geekaca\\chat\\meinv01 (2).jpg");
//        ImageIcon imageIcon = new ImageIcon(imgUrl);
//        JLabel label = new JLabel("确认");
//        label.setIcon(imageIcon);
//        label.setHorizontalAlignment(SwingConstants.HORIZONTAL);
        JTextField textField = new JTextField();
        JPasswordField jPasswordField = new JPasswordField();
        jPasswordField.setEchoChar('*');


        JButton btn = new JButton("确认");
        Container container = getContentPane();
        container.add(textField, BorderLayout.NORTH);
        container.add(jPasswordField);
        container.add(btn, BorderLayout.SOUTH);

        btn.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                // 按钮被点击 ,此函数会被调用

                String text = textField.getText();

                System.out.println("按钮被点击了.");
                System.out.println("输入内容是: " + text);
                System.out.println("密码是: " + jPasswordField.getPassword().toString());
            }
        });

        setVisible(true);
        setBounds(277, 277, 500, 400);
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

    }
}
